﻿using System;
using System.Web.UI.WebControls;

using HsTec.Mobile.Green.Util;
using HsTec.Mobile.Green.BLL;
using Baimasoft.Manage.SqlServerDAL;

public partial class ReportAnalysis_FileSpaceManage : System.Web.UI.Page
{
    EnergyProportionBLL bll = new EnergyProportionBLL();
    Param MyP = new Param();
    protected void Page_Load(object sender, EventArgs e)
    {
        if ((string)Session["Baimasoft_Pers_ID"] == null)
        {
            Response.Redirect("../Logon.aspx");
        }
        if (!this.IsPostBack)
        {
            try
            {
                Indicator.Text = Request.QueryString["sIndicator"].ToString();
            }
            catch
            {

            }
            GridView1.Attributes.Add("BorderColor", "LightSkyBlue");
            //this.BindGridViewData();
            this.BindsltArea();
        }
    }
    private void BindGridViewData()
    {
        GridView1.DataSource = bll.GetEnergyProportion(GetSearchString());
        GridView1.DataBind();
        HiddenID.Value = "";
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {

    }
    private string GetSearchString()
    {
        string searchStr = "(1=1)";

        string sddlRegionid = sltArea.SelectedValue.ToString().Trim();
        if (sddlRegionid != "")
        {
            searchStr += " and Area_ID  ='" + sddlRegionid + "' ";
        }
        if (sltMonth.Value != "")
        {
            searchStr += " and Years  ='" + sltYear.Value + sltMonth.Value + "' ";
        }
        return searchStr;
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        if (!String.IsNullOrEmpty(HiddenID.Value.Trim()))
        {
            bll.Delete(HiddenID.Value.TrimEnd(','));
            BindGridViewData();
        }
    }
    protected void linkBtnGo_Click(object sender, EventArgs e)
    {

    }
    private void BindsltArea()
    {
        sltArea.DataTextField = "Name";
        sltArea.DataValueField = "ID";
        sltArea.DataSource = bll.GetAreaList();
        sltArea.DataBind();
        sltArea.Items.Insert(0, "全省");
        sltArea.Items[0].Value = "";
    }
    protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
    {
        bll.GetList(GetSearchString()).Sort = e.SortExpression;
        this.BindGridViewData();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        this.BindGridViewData();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        BindGridViewData();
    }
}
